package com.redis.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.redis.Result.ResultBO;
import com.redis.entity.Goodsstore;
import com.redis.service.GoodsstoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 廖柏曦
 * @since 2022-03-01
 */
@Api(tags = "商品接口Api")
@Slf4j
@RestController
@RequestMapping("/redis/goodsstore")
public class GoodsstoreController extends ResultBO {

    @Resource
    private GoodsstoreService goodsstoreService;

    /**
     * 超时时间 5s
     */
    private static final int TIMEOUT = 5*1000;



    /**
     * 获取库存对象
     * @param code
     * @return
     */
    @ApiOperation(value = "获取库存对象")
    @GetMapping("/{code}")
    public ResultBO getGoodsstore(@PathVariable String code){
        if(StringUtils.isBlank(code)){
            return fail("code为空！");
        }else{
            QueryWrapper  goodsstoreWrapper=new QueryWrapper<>();
            goodsstoreWrapper.eq("code",code);
            return  success(200,goodsstoreService.getOne(goodsstoreWrapper));
        }
    }

}
